/****************************************************************************
**
** This file is part of qPhotoTag, a photo keywording application
**
** Copyright (C) 2009 Marcell Lengyel <miketkf@gmail.com>
**
** GNU General Public License
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**
****************************************************************************/

#ifndef __TAGLIST_H__
#define __TAGLIST_H__
/*! \file taglist.h
    \brief This file contains the declaration of the TagList class
 */

#include <QListView>
#include <QStringListModel>

//! A list view widget for displaying the IPTC keywords
/*!
  TagList a QListView subclass that is used to display QStrings.
 */
class TagList : public QListView
{
	Q_OBJECT
public:
    //! Constructor
    /*!
      Constructor for the TagList class.
      \param parent a QWidget pointer to the parent object
     */
    TagList(QWidget *parent = 0);
protected:
    //! Overriding the focusInEvent handler
    /*!
      The widget is emitting a tagListFocusIn() signal when it gains focus.
      \param e is a QFocusEvent pointer
     */
    void focusInEvent(QFocusEvent *e);

public:
    //! A method for adding new items to the list
    /*!
      The method checks that the newTag parameter is not empty and that the list
      does not contain the keyword yet. If both conditions are ok, then the list
      is updated and re-sorted alphabetically.

      \param newTag a contant QString that contains the IPTC keyword to be added to the list
     */
    void add_tag(const QString &newTag);
    //! A method for clearing the keyword list
    /*!
      This method removes all items from the list.
     */
    void clear();
    //! A method for checking if any items are selected from the list
    /*!
      This method can be used to check if there are any keywords selected from the
      keyword list.

      \return true if item(s) are selected
     */
    bool is_selection();
    //! A method for getting a QStringList with the selected keywords
    /*!
      This method returns a QStringList with the selected keywords or an empty
      QStringList if no items are selected.

      \return A QStringList with a list of the selected keywords
     */
    QStringList get_selected_tags();
    //! Not implemented yet
    void remove_selected_rows();
	
signals:
    //! A signal emitted when the widget gains focus
    /*!
      \sa focusInEvent()
     */
    void tagListFocusIn();
	
private:
    //! The model for storing the QListView data
    QStringListModel *tag_list_model;
};
#endif // __TAGLIST_H__
